/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.mto.module.karaoke.model;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.model.BaseModel;
import com.liferay.portal.model.impl.BaseModelImpl;

import com.mto.module.karaoke.service.SongLocalServiceUtil;

import java.io.Serializable;

import java.lang.reflect.Proxy;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @author vuonglm
 */
public class SongClp extends BaseModelImpl<Song> implements Song {
	public SongClp() {
	}

	public Class<?> getModelClass() {
		return Song.class;
	}

	public String getModelClassName() {
		return Song.class.getName();
	}

	public long getPrimaryKey() {
		return _songId;
	}

	public void setPrimaryKey(long primaryKey) {
		setSongId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_songId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	@Override
	public Map<String, Object> getModelAttributes() {
		Map<String, Object> attributes = new HashMap<String, Object>();

		attributes.put("songId", getSongId());
		attributes.put("songName", getSongName());
		attributes.put("songAuthor", getSongAuthor());
		attributes.put("songCategory", getSongCategory());
		attributes.put("songSinger", getSongSinger());
		attributes.put("recordNumber", getRecordNumber());
		attributes.put("songUrl", getSongUrl());
		attributes.put("createDate", getCreateDate());
		attributes.put("modifiedDate", getModifiedDate());
		attributes.put("audioUrl", getAudioUrl());

		return attributes;
	}

	@Override
	public void setModelAttributes(Map<String, Object> attributes) {
		Long songId = (Long)attributes.get("songId");

		if (songId != null) {
			setSongId(songId);
		}

		String songName = (String)attributes.get("songName");

		if (songName != null) {
			setSongName(songName);
		}

		String songAuthor = (String)attributes.get("songAuthor");

		if (songAuthor != null) {
			setSongAuthor(songAuthor);
		}

		Integer songCategory = (Integer)attributes.get("songCategory");

		if (songCategory != null) {
			setSongCategory(songCategory);
		}

		String songSinger = (String)attributes.get("songSinger");

		if (songSinger != null) {
			setSongSinger(songSinger);
		}

		Long recordNumber = (Long)attributes.get("recordNumber");

		if (recordNumber != null) {
			setRecordNumber(recordNumber);
		}

		String songUrl = (String)attributes.get("songUrl");

		if (songUrl != null) {
			setSongUrl(songUrl);
		}

		Date createDate = (Date)attributes.get("createDate");

		if (createDate != null) {
			setCreateDate(createDate);
		}

		Date modifiedDate = (Date)attributes.get("modifiedDate");

		if (modifiedDate != null) {
			setModifiedDate(modifiedDate);
		}

		String audioUrl = (String)attributes.get("audioUrl");

		if (audioUrl != null) {
			setAudioUrl(audioUrl);
		}
	}

	public long getSongId() {
		return _songId;
	}

	public void setSongId(long songId) {
		_songId = songId;
	}

	public String getSongName() {
		return _songName;
	}

	public void setSongName(String songName) {
		_songName = songName;
	}

	public String getSongAuthor() {
		return _songAuthor;
	}

	public void setSongAuthor(String songAuthor) {
		_songAuthor = songAuthor;
	}

	public int getSongCategory() {
		return _songCategory;
	}

	public void setSongCategory(int songCategory) {
		_songCategory = songCategory;
	}

	public String getSongSinger() {
		return _songSinger;
	}

	public void setSongSinger(String songSinger) {
		_songSinger = songSinger;
	}

	public long getRecordNumber() {
		return _recordNumber;
	}

	public void setRecordNumber(long recordNumber) {
		_recordNumber = recordNumber;
	}

	public String getSongUrl() {
		return _songUrl;
	}

	public void setSongUrl(String songUrl) {
		_songUrl = songUrl;
	}

	public Date getCreateDate() {
		return _createDate;
	}

	public void setCreateDate(Date createDate) {
		_createDate = createDate;
	}

	public Date getModifiedDate() {
		return _modifiedDate;
	}

	public void setModifiedDate(Date modifiedDate) {
		_modifiedDate = modifiedDate;
	}

	public String getAudioUrl() {
		return _audioUrl;
	}

	public void setAudioUrl(String audioUrl) {
		_audioUrl = audioUrl;
	}

	public BaseModel<?> getSongRemoteModel() {
		return _songRemoteModel;
	}

	public void setSongRemoteModel(BaseModel<?> songRemoteModel) {
		_songRemoteModel = songRemoteModel;
	}

	public void persist() throws SystemException {
		if (this.isNew()) {
			SongLocalServiceUtil.addSong(this);
		}
		else {
			SongLocalServiceUtil.updateSong(this);
		}
	}

	@Override
	public Song toEscapedModel() {
		return (Song)Proxy.newProxyInstance(Song.class.getClassLoader(),
			new Class[] { Song.class }, new AutoEscapeBeanHandler(this));
	}

	@Override
	public Object clone() {
		SongClp clone = new SongClp();

		clone.setSongId(getSongId());
		clone.setSongName(getSongName());
		clone.setSongAuthor(getSongAuthor());
		clone.setSongCategory(getSongCategory());
		clone.setSongSinger(getSongSinger());
		clone.setRecordNumber(getRecordNumber());
		clone.setSongUrl(getSongUrl());
		clone.setCreateDate(getCreateDate());
		clone.setModifiedDate(getModifiedDate());
		clone.setAudioUrl(getAudioUrl());

		return clone;
	}

	public int compareTo(Song song) {
		long primaryKey = song.getPrimaryKey();

		if (getPrimaryKey() < primaryKey) {
			return -1;
		}
		else if (getPrimaryKey() > primaryKey) {
			return 1;
		}
		else {
			return 0;
		}
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		SongClp song = null;

		try {
			song = (SongClp)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = song.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(21);

		sb.append("{songId=");
		sb.append(getSongId());
		sb.append(", songName=");
		sb.append(getSongName());
		sb.append(", songAuthor=");
		sb.append(getSongAuthor());
		sb.append(", songCategory=");
		sb.append(getSongCategory());
		sb.append(", songSinger=");
		sb.append(getSongSinger());
		sb.append(", recordNumber=");
		sb.append(getRecordNumber());
		sb.append(", songUrl=");
		sb.append(getSongUrl());
		sb.append(", createDate=");
		sb.append(getCreateDate());
		sb.append(", modifiedDate=");
		sb.append(getModifiedDate());
		sb.append(", audioUrl=");
		sb.append(getAudioUrl());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(34);

		sb.append("<model><model-name>");
		sb.append("com.mto.module.karaoke.model.Song");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>songId</column-name><column-value><![CDATA[");
		sb.append(getSongId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>songName</column-name><column-value><![CDATA[");
		sb.append(getSongName());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>songAuthor</column-name><column-value><![CDATA[");
		sb.append(getSongAuthor());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>songCategory</column-name><column-value><![CDATA[");
		sb.append(getSongCategory());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>songSinger</column-name><column-value><![CDATA[");
		sb.append(getSongSinger());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>recordNumber</column-name><column-value><![CDATA[");
		sb.append(getRecordNumber());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>songUrl</column-name><column-value><![CDATA[");
		sb.append(getSongUrl());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>createDate</column-name><column-value><![CDATA[");
		sb.append(getCreateDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
		sb.append(getModifiedDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>audioUrl</column-name><column-value><![CDATA[");
		sb.append(getAudioUrl());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private long _songId;
	private String _songName;
	private String _songAuthor;
	private int _songCategory;
	private String _songSinger;
	private long _recordNumber;
	private String _songUrl;
	private Date _createDate;
	private Date _modifiedDate;
	private String _audioUrl;
	private BaseModel<?> _songRemoteModel;
}